package com.zwr.sheller.sso.Service.impl;

import com.zwr.sheller.core.util.SMSSend;
import com.zwr.sheller.sso.Service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @Author: 18032
 * @Date: 16:52 2022/1/10
 */
@Service
public class SmsServiceImpl implements SmsService {
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    public static  final String LOGIN_SMS="login_sms:";
    @Override
    public String sendLoginSms(String phone) {
        String msgCode = SMSSend.getMsgCode();
        System.out.println("++++++++验证码:"+msgCode+"+++++++++");
        //服务器这是失效时间为30min
        redisTemplate.opsForValue().set(LOGIN_SMS+phone,msgCode,30, TimeUnit.MINUTES);
        return msgCode;
    }
}
